home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / GetFile.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  3KB  |  112 lines

  1. /*
  2.  * getfile.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: February 28, 1993
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.0
  9.  */
  10. call pragma('stack',20000);
  11.  
  12.  
  13. /*
  14.  * open rexxsupport.library -- needed for some functions
  15.  */
  16. if ~show('L',"rexxsupport.library") then do
  17.   if addlib('rexxsupport.library',0,-30,0) then do
  18.       /* everything's ok */
  19.     end;
  20.   else do
  21.     exit 10;
  22.     end;
  23.   end;
  24.  
  25. prtnme = 'IP_Port'; /* assume Image Professional */
  26. if show('P','IP_Port') = 0 then do
  27.   if show('P','IM_Port') = 0 then do
  28.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  29.     say "This script requires IP, IM or IM F/c to run!";
  30.     exit(20);
  31.     end;
  32.   else do
  33.     prtnme = 'IM_Port';
  34.     end;
  35.   end;
  36.  
  37. options;
  38. address;
  39.  
  40.   prevpath = 'ram:'; /* put user in ram to start with... */
  41.  
  42.   if show('C', imloadpath) = 1 then do
  43.     prevpath = getclip(imloadpath);
  44.     end;
  45.  
  46.   address(prtnme);
  47.   options results;
  48.   'filerequest "'||prevpath||'","","","Select File"';
  49.   lfile = result;
  50.   options;
  51.  
  52.   if lfile = 'FR_CANCELLED' then do
  53.     exit 10;
  54.     end;
  55.  
  56.   lfile = expandfilename(lfile);
  57.   thispath = gimmepath(lfile);
  58.   call setclip(imloadpath, thispath);
  59.  
  60.   call open(fhandle,'ram:IP_FNAME.tmp','write');      /* open the file */
  61.   junk = writeln(fhandle, lfile);
  62.   call close(fhandle);                     /* close the file    */
  63.   
  64.   exit 0;
  65.  
  66. /*
  67.  * gimmepath
  68.  *
  69.  * This takes the provided argument and sucks the path out of it, then
  70.  * returns that path to the caller, sans file name.
  71.  */
  72. gimmepath:
  73.   arg fullnamegx;
  74.     tempgx = reverse(fullnamegx);
  75.     lengx = length(fullnamegx);   /* get length of string */
  76.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  77.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  78.     seploc = 0; /* assumes current dir, no path supplied */
  79.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  80.       seploc = (lengx - slashdex)+1;
  81.       end;
  82.     else do
  83.       if colondex ~= 0 then do /* we assume we are on a device */
  84.         seploc = (lengx - colondex)+1;
  85.         end;
  86.       end;
  87.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  88.   gxpath = left(fullnamegx,seploc);
  89.   return(gxpath);
  90.  
  91. /*
  92.  * Since this script can't be expected to know where the CD of the user
  93.  * is when this cmd is invoked, we have to check the path the user
  94.  * provides - if it's not specified right from a root, then we have
  95.  * to make it a complete specification from the root.
  96.  */
  97. expandfilename:
  98.   parse arg jfile;
  99.   if index(jfile,':') = 0 then do
  100.     curdir = pragma(D);
  101.     if right(curdir,1) ~= ':' then do
  102.       if right(curdir,1) ~= '/' then do
  103.         if curdir ~= '' then do
  104.           curdir = curdir || '/';
  105.           end;
  106.         end;
  107.       end;
  108.     jfile = curdir||jfile;
  109.     end;
  110.   return(jfile);
  111.  
  112.